<!doctype html>
<html>
    <head>
        <title>体征历史记录</title>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <link rel="stylesheet" type="text/css" href="../../css/jquery.mobile-1.4.0.css" />
        <link rel="stylesheet" type="text/css" href="../../css/zpdydhl_mobile.css">
        <link rel="stylesheet" type="text/css" href="../../css/mobiscroll.custom-2.6.2.min.css">
        <script type="text/javascript" src="../../js/jquery-1.8.3.min.js"></script>
        <script type="text/javascript" src="../../js/zpdydhl_mobile.js"></script>
        <script type="text/javascript" src="../../js/mobiscroll.custom-2.6.2.min.js"></script>
        <style>
            .tizheng_one {
                /*font-weight: bold;*/
                font-size: 14px;
                width: 100%;
                text-align: center;
            }

            .tizheng_jiancha_time {
                width:23%;
                /*color: #0D85C0;*/
            }

            .tizheng_jiancha_type {
                width:19%;
                /*color: #0D85C0;*/
            }

            .tizheng_jiancha_fangshi {
                width:19%;
                /*color: #0D85C0;*/
            }

            .tizheng_jiancha_value {
                width:19%;
                /*color: #818181;*/
            }

            .tizheng_jiancha_manage {
                font-weight: bold;
                width:19%;
                color: red;
            }

            .tizheng_history_button {
                background-color: #279bce;
                color: #FFF;
                border-radius: 5px;
                height: 25px;
                font-size: 12px;
            }
            .tab-title {
                width: 100%;
                background-color: #f5f1fe;
                height: 40px;
                line-height: 40px;
            }
            .tizheng_one {
                width: 95%;
                margin: 0 auto;
                border-collapse: collapse;
            }
            .tizheng_one tr td {
                border: 1px solid #eeebf0;
            }
            .tizheng_list_new tr td {
                height: 35px;
                line-height: 35px;
            }
        </style>
    </head>
    <body>
        <div class="ui-page ui-page-theme-c ui-page-header-fixed ui-page-active ttm_ui_page" style="padding-top: 0;">
            <table width="97%" border="0" height="52" style="margin-left:10px;">
                <tr id="type_nav">
                    <td>
                        <input type="button" value="体温" id="jiancha_type_tiwen" class="tizheng_history_button" data-role="none" style="margin-left:0px;"/>
                    </td>
                    <td>
                        <input type="button" value="脉搏" id="jiancha_type_mibo" class="tizheng_history_button" data-role="none" style="margin-left:0px;"/>
                    </td>
                    <td>
                        <input type="button" value="血压" id="jiancha_type_xueya" class="tizheng_history_button" data-role="none" style="margin-left:0px;"/>
                    </td>
                    <td>
                        <input type="button" value="其他" id="jiancha_type_others" class="tizheng_history_button" data-role="none" style="margin-left:0px;"/>
                    </td>
                </tr>
            </table>
            <div data-role="content" class="content" style="">
                <div style="">
                    <table class="tizheng_one" border="0" cellpadding="0" cellspacing="0">
                        <thead class="tab-title">
                            <tr class="" style="font-weight:bold;">
                                <td class="tizheng_jiancha_time">录入时间</td>
                                <td class="tizheng_jiancha_type">检查类型</td>
                                <td class="tizheng_jiancha_fangshi">检查方式</td>
                                <td class="tizheng_jiancha_value">检查值</td>
                            </tr>
                        </thead>
                        <tbody class="tizheng_list_new">

                        </tbody>
                    </table>
                </div>
            </div>

        </div>
        <script type='text/javascript'>
     	// 体征录入时间(根据此时间进行筛选查看体征录入历史)
        var tizheng_jiancha_date = getRequestOne("tizheng_jiancha_date");
        var count = getRequestOne("count");


		//window.setTimeout("getTizhengListByTime('"+tizheng_jiancha_date+"',0)",1000);
		//setTimeout(“getTizhengListByTime(”+url+“)”, 100);


            // 体征录入类型(根据此类型筛选查看体征录入历史)
            var tizheng_jiancha_type = null;
            $(function () {
				setGetHeader();//getTizhengListByTime(tizheng_jiancha_date,0);
				//setHeader();
                var page_before_tizhenglishi = getRequestOne("page_before_tizhenglishi");
                if(page_before_tizhenglishi=="tizhengLuru")
                {
                    document_type_global = app_path+"page/tizheng/lishiTizheng_type";
                    getTizhengListByType("体温");
                }
                else
                {
                    $("#time a").addClass('ui-btn-active');
                    $("#time a").css("color","#ffffff");
                    $("#type a").removeClass('ui-btn-active');
                    $("#type a").css("color","#0D85C0");

                    $("#time_nav").css("display","");
                    $("#type_nav").css("display","none");

                    document_type_global = "lishiTizheng_time";
                    getTizhengListByTime(tizheng_jiancha_date,0);
                }

                // 体征查看切换
                // 前一天
                $("#jiancha_time_prev").die().live("click",function(){
                    getTizhengListByTime(tizheng_jiancha_date,-1);
                });

                // 后一天
                $("#jiancha_time_next").die().live("click",function(){
                    getTizhengListByTime(tizheng_jiancha_date,1);
                });

                // 今天
                $("#jiancha_time_current_day").die().live("click",function(){
                    getTizhengListByTime(null,0);
                });

                // 显示三测单
                $("#show_sancedan").die().live("click",function(){
                    window.location.href = "./showSancedan.html?count="+count+"&tizheng_jiancha_date="+tizheng_jiancha_date+"&page_before_tizhenglishi="+page_before_tizhenglishi;
                });

                // 体温
                $("#jiancha_type_tiwen").die().live("click",function(){
                    getTizhengListByType("体温");
                });

                // 脉搏
                $("#jiancha_type_mibo").die().live("click",function(){
                    getTizhengListByType("脉搏");
                });

                // 血压
                $("#jiancha_type_xueya").die().live("click",function(){
                    getTizhengListByType("血压");
                });

                // 其他
                $("#jiancha_type_others").die().live("click",function(){
                    getTizhengListByType("其他");
                });

                // 选项卡切换
                $(".tizheng_show_mode").die().live("click",function(){
                    var tizheng_show_mode = $(this).attr("tizheng_show_mode");
                    if(tizheng_show_mode=='time')
                    {

                        $("#time a").addClass('ui-btn-active');
                        $("#time a").css("color","#ffffff");
                        $("#type a").removeClass('ui-btn-active');
                        $("#type a").css("color","#0D85C0");

                        $("#time_nav").css("display","");
                        $("#type_nav").css("display","none");

                        document_type_global = "lishiTizheng_time";
                        getTizhengListByTime(tizheng_jiancha_date,0);
                    }
                    else
                    {
                        $("#type a").addClass('ui-btn-active');
                        $("#type a").css("color","#ffffff");
                        $("#time a").removeClass('ui-btn-active');
                        $("#time a").css("color","#0D85C0");

                        $("#time_nav").css("display","none");
                        $("#type_nav").css("display","");

                        document_type_global = "lishiTizheng_type";
                        getTizhengListByType(tizheng_jiancha_type);
                    }
                });

                $(".delete_tizheng").die().live("click",function(){
                    if(confirm("是否确认删除此条体征记录?"))
                    {
                        var tizheng_table = $(this).parent().parent().parent();
                        var zhuyuan_tizheng_id = $(this).attr("zhuyuan_tizheng_id");
                        var hushi_id = nurse_info_global.user_number;
                        //if(hushi_id) alert('自己只能删除自己添加的记录或者请找护士长删除');return;
                        $.ajax({
                            type: "get",
                            async: true,
                            url:server_url+"Mobile/Tizheng/deleteTizheng/zhuyuan_tizheng_id/"+zhuyuan_tizheng_id+'/hushi_id/'+hushi_id+yiyuan_id,
                            data:{},
                            dataType: "jsonp",
                            jsonp: "callbackDeleteTizheng",
                            jsonpCallback:"feedBackStateDeleteTizheng",
                            error:function(mes)
                            {
                                alert("请求失败，请稍后重试");
                            },
                            success: function(result) {
                                if(result.ret == 'success'){
                                    $(tizheng_table).next().remove();
                                    $(tizheng_table).remove();
                                }else{
                                    alert('自己只能删除自己添加的记录或者请找护士长删除');return;
                                }

                            }
                        });
                    }
                });

                //点击返回按钮
                $("#fanhui_tizhengluru").die().live("click",function(){
                    if(page_before_tizhenglishi=="tizhengLuru")
                    {
                        window.location.href = "./tizhengluru.html";
                    }
                    else
                    {
                        window.location.href = "../Patient/showTizhengList.html";
                    }
                });

            });

            //根据时间获取体征录入历史
            function getTizhengListByTime(jiancha_date,offset){
				if(null == server_url || "" == server_url){
					return;
				}
                //向后台请求数据
                $.ajax({
                    type: "get",
                    async: false,
                    url:server_url+"Mobile/Tizheng/showTizhengByTimeJson/zhuyuan_id/"+zhuyuan_id+"/jiancha_date/"+jiancha_date+"/offset/"+offset+yiyuan_id,
                    data:{},
                    dataType: "jsonp",
                    jsonp: "callbackGetListTizheng",
                    jsonpCallback:"feedBackStateGetListTizheng",
                    error:function(mes)
                    {
                        alert("请求失败，请稍后重试");
                    },
                    beforeSend: loading,
                    success: function(result) {

						var str_html ="";
                        if(result.ret=="success")
                        {
                            var tingzheng_info_list = result.data.zhuyuan_tizheng_list;
                            str_html = '';
                            if(tingzheng_info_list != null)
                            {
                                for(var i=0;i<tingzheng_info_list.length;i++)
                                {
                                    str_html += '<tr class="">'+
                                                    '<td class="tizheng_jiancha_time">'+tingzheng_info_list[i]["jiancha_time"]+'</td>'+
                                                    '<td class="tizheng_jiancha_type">'+tingzheng_info_list[i]["jiancha_type"]+'</td>'+
                                                    '<td class="tizheng_jiancha_fangshi">'+tingzheng_info_list[i]["jiancha_fangshi"]+'</td>'+
                                                    '<td class="tizheng_jiancha_value">'+tingzheng_info_list[i]["jiancha_value"]+'</td>'+
                                                '</tr>';
                                }
                            }
                            $(".tizheng_list_new").html(str_html);

                            // 设置体征日期
                            tizheng_jiancha_date = result.data.jiancha_date;
                            /*加载loding消失*/
                            $('#m').remove();
                            $('#lo').remove();
                            /*end*/
                        }
                        else
                        {
                            alert("失败");
                        }
                    }
                });
            }

            //根据类型获取体征录入历史
            function getTizhengListByType(jiancha_type){
                //向后台请求数据
                $.ajax({
                    type: "get",
                    async: false,
                    url:server_url+"Mobile/Tizheng/showTizhengByTypeJson/zhuyuan_id/"+patient_info_global.zhuyuan_id+"/jiancha_type/"+jiancha_type+yiyuan_id,
                    data:{user_number:nurse_info_global.user_number},
                    dataType: "jsonp",
                    jsonp: "callbackGetTizhengListByType",
                    jsonpCallback:"feedBackStateGetTizhengListByType",
                    error:function(mes)
                    {
                        alert("请求失败，请稍后重试");
                    },
                    success: function(result) {
                        if(result.ret=="success")
                        {
                            var tingzheng_info_list = result.data.zhuyuan_tizheng_list;
                            var str_html = '<table class="tizheng_one">'+
                                                '<tr class="" style="font-weight:bold;">'+
                                                    '<td class="tizheng_jiancha_time">录入时间</td>'+
                                                    '<td class="tizheng_jiancha_type">检查类型</td>'+
                                                    '<td class="tizheng_jiancha_fangshi">检查方式</td>'+
                                                    '<td class="tizheng_jiancha_value">检查值</td>'+
                                                    '<td class="tizheng_jiancha_manage">管理</td>'+
                                                '</tr>'+
                                            '</table>'+
                                            '<hr/>';
                            if(tingzheng_info_list != null)
                            {
                                for(var i=0;i<tingzheng_info_list.length;i++)
                                {
                                    str_html += '<table class="tizheng_one">';
                                    str_html += '<tr class="">'+
                                                    '<td class="tizheng_jiancha_time">'+tingzheng_info_list[i]["jiancha_time"]+'</td>'+
                                                    '<td class="tizheng_jiancha_type">'+tingzheng_info_list[i]["jiancha_type"]+'</td>'+
                                                    '<td class="tizheng_jiancha_fangshi">'+tingzheng_info_list[i]["jiancha_fangshi"]+'</td>'+
                                                    '<td class="tizheng_jiancha_value">'+tingzheng_info_list[i]["jiancha_value"]+'</td>'+
                                                    '<td class="tizheng_jiancha_manage delete_tizheng" hushi_id="'+tingzheng_info_list[i]["jiancha_doctor_id"]+'"zhuyuan_tizheng_id="'+tingzheng_info_list[i]["id"]+'">删除</td>'+
                                                '</tr>';
                                    str_html += '</table>'+
                                        '<hr/>';

                                }
                            }
                            $(".tizheng_list_new").html(str_html);

                            // 设置体征类型
                            tizheng_jiancha_type = result.data.jiancha_type;
                        }
                        else
                        {
                            alert("失败");
                        }
                    }
                });
            }
        </script>
    </body>
</html>
